package org.xzx.shop_api.config;
import org.xzx.shop_api.interceptor.ShopInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    private ShopInterceptor shopInterceptor;
    //配置拦截器的映射
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(shopInterceptor).
                addPathPatterns("/api/members/*").
                excludePathPatterns("/api/api_account/*");
        //addPathPatterns:需要拦截的路由或模块
        //excludePathPatterns:排除哪些不需要拦截
    }
}
